from aiogram_dialog import Dialog, DialogManager, Window
from aiogram_dialog.widgets.kbd import Button, Cancel, Start, Url
from aiogram_dialog.widgets.text import Format

from poker_bot.config import Settings
from poker_bot.tg_bot.dialogs.widgets import LocaleText
from poker_bot.tg_bot.states import CheckSubscribeSG, CreateDepositSG

from .handlers import check_subscription


async def social_media_getter(
    dialog_manager: DialogManager, config: Settings, **kwargs
):
    return {
        "tg_link": f"https://t.me/{config.tg_bot.group_to_subscribe_username}",
        "instagram_link": f"https://instagram.com/{config.tg_bot.instagram_username}",
    }


social_media_window = Window(
    LocaleText("subscribe-to-social-media-msg"),
    Url(LocaleText("tg-channel-btn"), Format("{tg_link}")),
    Url(LocaleText("instagram-profile-btn"), Format("{instagram_link}")),
    Button(
        LocaleText("check-subscribtion-btn"),
        "check_subscription",
        on_click=check_subscription,
    ),
    Start(
        LocaleText("skip-subscription-btn"),
        id="skip_btn",
        state=CreateDepositSG.select_payment_method,
    ),
    Cancel(LocaleText("back-btn")),
    state=CheckSubscribeSG.display_social_media,
    getter=social_media_getter,
)

check_subscribtion_dialog = Dialog(social_media_window)
